/*
 $Id$

 Copyright (C) 2006-2007 by David Cotton

 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
 Foundation; either version 2 of the License, or (at your option) any later
 version.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

 You should have received a copy of the GNU General Public License along with
 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
package fr.free.jchecs.core.move;

import fr.free.jchecs.core.Square;
import fr.free.jchecs.core.board.Board;

/**
 * Interface that is provided by the classes to generate movement.
 * 
 * @author David Cotton
 */
public interface MoveGenerator extends Board {
	/**
	 * Returns a new instance initialized from any state.
	 * 
	 * @param pEtat
	 *            State of beginning.
	 * @return Copy of the statement.
	 */
	MoveGenerator derive(final Board pEtat);

	/**
	 * Returns a new instance describing the state of the game after application
	 * of a movement.
	 * 
	 * @param pMouvement
	 *            Description of movement.
	 * @param pSuivant
	 *            Flag set if it is desired that the line be amended.
	 * @return Instance derived.
	 */
	MoveGenerator derive(final Move pMouvement, final boolean pSuivant);

	/**
	 * Divert all possible movements of target cells (including those involving
	 * the king in check) for the part contained by a box.
	 * 
	 * @param pOrigine
	 *            Check the origin of the movement.
	 * @return List of target cells (including those leading to a failure).
	 */
	Square[] getAllTargets(final Square pOrigine);

	/**
	 * Divert all fields possible targets of a movement like "crazy"in a certain
	 * color (including putting the king in check) from a box.
	 * 
	 * @param pOrigine
	 *            Check the origin of the movement.
	 * @param pBlanc
	 *            Set to true if the search for whites.
	 * @return List of target cells (including those leading to a failure).
	 */
	Square[] getBishopTargets(final Square pOrigine, final boolean pBlanc);

	/**
	 * Reference box containing the king of a color.
	 * 
	 * @param pCouleur
	 *            Set to "true " if you search for the white king, to false
	 *            otherwise.
	 * @return Box containing the king.
	 */
	Square getKingSquare(final boolean pCouleur);

	/**
	 * Reference list of boxes that can be achieved by a King-type movement.
	 * 
	 * @param pOrigine
	 *            Check the origin of the movement.
	 * @param pBlanc
	 *            A true to indicate a search for whites.
	 * @return List of target cells (including those leading to a failure).
	 */
	Square[] getKingTargets(final Square pOrigine, final boolean pBlanc);

	/**
	 * Reference list of boxes that can be achieved by movement type rider.
	 * 
	 * @param pOrigine
	 *            Check the origin of the movement.
	 * @param pBlanc
	 *            A true to indicate a search for whites.
	 * @return List of target cells (including those leading to a failure).
	 */
	Square[] getKnightTargets(final Square pOrigine, final boolean pBlanc);

	/**
	 * Reference list of boxes that can be achieved by a pin-type movement.
	 * 
	 * @param pOrigine
	 *            Case à l'origine du mouvement.
	 * @param pBlanc
	 *            A true to indicate a search for whites.
	 * @return List of target cells (including those leading to a failure).
	 */
	Square[] getPawnTargets(final Square pOrigine, final boolean pBlanc);

	/**
	 * Divert all fields possible targets of a movement like "lady" of a certain color (including putting the king in check) from a box.
	 * 
	 * @param pOrigine
	 *            Check the origin of the movement.
	 * @param pBlanc
	 *            Set to true to search for whites.
	 * @return List of target cells (including those leading to a failure).
	 */
	Square[] getQueenTargets(final Square pOrigine, final boolean pBlanc);

	/**
	 * Divert all fields possible targets of a movement-type "tower" of a
	 * certain color (including putting the king in check) from a box.
	 * 
	 * @param pOrigine
	 *            Check the origin of the movement.
	 * @param pBlanc
	 *            Set to true to search for whites.
	 * @return List of target cells (including those leading to a failure).
	 */
	Square[] getRookTargets(final Square pOrigine, final boolean pBlanc);

	/**
	 * Divert all movements valid for one color.
	 * 
	 * @param pTrait
	 *            Set to "true" to indicate a search for whites.
	 * @return List of valid movements.
	 */
	Move[] getValidMoves(final boolean pTrait);

	/**
	 * Divert all boxes movements valid targets from a box.
	 * 
	 * @param pOrigine
	 *            Check the origin of the movement.
	 * @return List of boxes targets.
	 */
	Square[] getValidTargets(final Square pOrigine);

	/**
	 * Indicates whether a cell is attacked by a color.
	 * 
	 * @param pCible
	 *            Cible Case.
	 * @param pCouleur
	 *            Set to "true" to test the attack by whites.
	 * @return True if the box is contested.
	 */
	boolean isAttacked(final Square pCible, final boolean pCouleur);

	/**
	 * Indicates if the King has castled in color.
	 * 
	 * @param pBlanc
	 *            Set to "true " to get the status of whites.
	 * @return A "true" if the corresponding castled king.
	 */
	boolean isCastled(final boolean pBlanc);

	/**
	 * Indicates whether the king of color is in check.
	 * 
	 * @param pCouleur
	 *            Set to "true " for test failure on white, to false otherwise.
	 * @return True if the king is in check.
	 */
	boolean isInCheck(final boolean pCouleur);
}
